#!/bin/bash
if ! command -v docker-compose >/dev/null 2>&1;then
  echo "docker-compose命令不存在，现在开始安装...."
  sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose;
  if [ $? -ne 0];then
    echo "docker-compose命令下载失败！"
    exit_script
  fi
  sudo chmod +x /usr/local/bin/docker-compose;
  echo "docker-compose命令安装完成。"
fi
# 删除容器
sudo docker-compose -f db-docker-compose.yaml down

# 启动所有容器
sudo docker-compose -f db-docker-compose.yaml up -d

# 退出命令行
exit_script() {
  exit 1
}
